package cn.dong.base.handler;

import cn.dong.api.domain.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomException extends RuntimeException{

    /**状态码,默认继承了message*/
    private Integer code;

    /**
     * 接受状态码和消息
     * @param code
     * @param message
     */
    public CustomException(Integer code, String message) {
        super(message);
        this.code=code;
    }

    /**
     * 接受状态码和消息
     * @param resultCodeEnum
     */
    public CustomException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code=resultCodeEnum.getCode();
    }

}
